local skill = fk.CreateSkill{
  name = "tea__debao",
}
---@type TrigSkelSpec<TrigFunc>
local debao = {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skill.name) and target == player
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local num = #player:getCardIds("h")
    local _num = 0
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if not p.dead and #p:getCardIds("h") > 0 then     
        local cids = room:askToCards(p, {
          min_num = 1,
          max_num = 999,
          skill_name = skill.name,
          prompt = "#tea__debao-choose:" .. player.id .. "::" .. tostring(num),
        })
        if #cids > 0 then
          _num = _num + #cids
          room:moveCardTo(cids, Card.DrawPile, nil, fk.ReasonPut, skill.name, nil, false, p)
        end
      end
    end
    if _num >= num then
      room:recover{
        who = player,
        num = 1,
        skillName = skill.name
      }
      if not player.dead and num > 0 then
        player:drawCards(num, skill.name)
        if not player.dead then
          room:setPlayerMark(player, "@@tea__debao_mark-round", 1)
          room:invalidateSkill(player, skill.name, "-round")
        end
      end 
    end
  end,
}
skill:addEffect(fk.EnterDying, debao)
return skill